package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhCarAlias;
import com.laowang.project.system.service.MyCyhCarAliasService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 车别名Controller
 *
 * @author laowang
 * @date 2023-06-13
 */
@Api(tags = "车别名接口")
@RestController
@RequestMapping("/carAlias")
public class MyCyhCarAliasController extends BaseController {
    @Autowired
    private MyCyhCarAliasService myCyhCarAliasService;

    /**
     * 查询车别名列表
     */
    @ApiOperation(value = "小程序端 查询车类型 ",notes = "")
    @GetMapping("/web/list")
    public AjaxResult weblist() {

        List<MyCyhCarAlias> list = myCyhCarAliasService.selectMyCyhCarAliasList(null);
        return AjaxResult.success("操作成功",list);
    }

    /**
     * 查询车别名列表
     */
    @ApiOperation(value = "查询车别名列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carAlias:list')")
    @GetMapping("/list")
        public TableDataInfo list(MyCyhCarAlias myCyhCarAlias) {
        startPage();
        List<MyCyhCarAlias> list = myCyhCarAliasService.selectMyCyhCarAliasList(myCyhCarAlias);
        return getDataTable(list);
    }

    /**
     * 导出车别名列表
     */
    @ApiOperation(value = "导出车别名列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carAlias:export')")
    //@Log(title = "车别名", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyCyhCarAlias myCyhCarAlias) {
        List<MyCyhCarAlias> list = myCyhCarAliasService.selectMyCyhCarAliasList(myCyhCarAlias);
        ExcelUtil<MyCyhCarAlias> util = new ExcelUtil<MyCyhCarAlias>(MyCyhCarAlias.class);
        return util.exportExcel(list, "carAlias");
    }

    /**
     * 获取车别名详细信息
     */
    @ApiOperation(value = "获取车别名详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carAlias:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhCarAliasService.selectMyCyhCarAliasById(id));
    }

    /**
     * 新增车别名
     */
    @ApiOperation(value = "新增车别名",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carAlias:add')")
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhCarAlias myCyhCarAlias) {
        return toAjax(myCyhCarAliasService.insertMyCyhCarAlias(myCyhCarAlias));
    }

    /**
     * 修改车别名
     */
    @ApiOperation(value = "修改车别名",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carAlias:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhCarAlias myCyhCarAlias) {
        return toAjax(myCyhCarAliasService.updateMyCyhCarAlias(myCyhCarAlias));
    }

    /**
     * 删除车别名
     */
    @ApiOperation(value = "删除车别名",notes = "")
    @PreAuthorize("@ss.hasPermi('my:carAlias:remove')")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhCarAliasService.deleteMyCyhCarAliasByIds(ids));
    }
}
